clear
set mem 10000m
set more off 

cd "C:\Users\lzeng\Dropbox\Reseach\Soccer project\Gilje Taillard Zeng_Replication"

/*Import the dataset for the main analysis*/
use Main_Analysis_Data.dta

/*Table 2: Summary statistics -- Panel A: Club-level summary statistics*/
preserve 
collapse (count) player = player_identification, by(shock_club_year)
sum player, d
restore

/*Table 2: Summary statistics -- Panel B: Player-level summary statistics*/

estpost sum age tenure shock_pre0_appearance shock_pre0_minutes shock_pre0_goals shock_pre0_assists pre_appearance_all  pre_minutes_all pre_goals_all pre_assists_all stay summer_transfer PL post_appearance_pl post_minutes_pl post_goals_pl post_assists_pl,d

/*Table 2: Summary statistics -- Panel C: Composition of players*/

tab position

/*Table 3: Validity of empirical design -- Panel B: Player-level regressions*/

eststo:areg shock_pre0_appearance treated, absorb(shock_year) cluster(shock_club_year)

eststo:areg shock_pre0_minutes treated, absorb(shock_year) cluster(shock_club_year)

eststo:areg shock_pre0_goals treated, absorb(shock_year) cluster(shock_club_year)

eststo:areg shock_pre0_assists treated, absorb(shock_year) cluster(shock_club_year)

eststo:areg pre_appearance_all treated, absorb(shock_year) cluster(shock_club_year)

eststo:areg pre_minutes_all treated, absorb(shock_year) cluster(shock_club_year)

eststo:areg pre_goals_all treated, absorb(shock_year) cluster(shock_club_year)

eststo:areg pre_assists_all treated, absorb(shock_year) cluster(shock_club_year)

eststo:areg age treated, absorb(shock_year) cluster(shock_club_year)

eststo:areg tenure treated, absorb(shock_year) cluster(shock_club_year)

esttab using Table3_PanelB.csv, starlevels(* 0.1 ** 0.05 *** 0.01) r2(2) replace
eststo clear

/*Figure 2: Timing of human capital redeployment*/

gen stay_group = 1 if stay <= 3 & stay !=.
replace stay_group = 2 if stay > 3 & stay <= 24 & stay !=.
replace stay_group = 3 if stay > 24 & stay !=.

preserve 
drop if stay_group == .
collapse (count) player = player_identification, by (treated stay_group)
by treated, sort: egen total_player = total(player)
gen percentage = player / total_player
gen Treatment = percentage if treated == 1
gen Control = percentage if treate == 0
drop percentage
collapse (sum) Treatment Control, by(stay_group)
graph bar Treatment Control, over(stay_group, relabel(1 "<4" 2 "4-24" 3 ">24")) legend(label(1 "Treatment") label(2 "Control") ) 
graph export Figure2.pdf, replace
restore

/*Table 4: Timing of human capital redeployment*/

eststo: areg stay treated, absorb(shock_year) cluster(shock_club_year)

eststo: areg summer_transfer treated, absorb(shock_year) cluster(shock_club_year)

eststo: logit summer_transfer treated i.shock_year, cluster(shock_club_year) or

esttab using Table4.csv, starlevels(* 0.1 ** 0.05 *** 0.01) r2(2) replace
eststo clear

/*Table 5: Parachute payment and timing of human capital redeployment*/

gen post2005 = 0
replace post2005 = 1 if shock_year > 2005
gen treated_post2005 = treated * post2005

eststo: areg stay treated treated_post2005 if shock_year >= 2001 & shock_year <= 2010, absorb(shock_year) cluster(shock_club_year)
test treated + treated_post2005= 0

eststo: areg summer_transfer treated treated_post2005 if shock_year >= 2001 & shock_year <= 2010, absorb(shock_year) cluster(shock_club_year)
test treated + treated_post2005= 0

eststo: logit summer_transfer treated treated_post2005 i.shock_year if shock_year >= 2001 & shock_year <= 2010, cluster(shock_club_year) or
test treated + treated_post2005= 0

esttab using Table5.csv, starlevels(* 0.1 ** 0.05 *** 0.01) r2(2) replace
eststo clear

/*Table 6: Ownership and timing of human capital redployment*/

gen duration_high = 0
replace duration_high = 1 if duration > 10 /*10 is the median of duration*/

gen control = 0
replace control = 1 if controlling == "yes"
gen duration_control = duration_high * control

eststo: areg stay treated##duration_high, absorb(shock_year) cluster(shock_club_year)

eststo: areg summer_transfer treated##duration_high, absorb(shock_year) cluster(shock_club_year)

eststo: logit summer_transfer treated##duration_high i.shock_year, cluster(shock_club_year) or

eststo: areg stay treated##control, absorb(shock_year) cluster(shock_club_year)

eststo: areg summer_transfer treated##control, absorb(shock_year) cluster(shock_club_year)

eststo: logit summer_transfer treated##control i.shock_year, cluster(shock_club_year) or

eststo: areg stay treated##duration_control, absorb(shock_year) cluster(shock_club_year)

eststo: areg summer_transfer treated##duration_control, absorb(shock_year) cluster(shock_club_year)

eststo: logit summer_transfer treated##duration_control  i.shock_year, cluster(shock_club_year) or

esttab using Table6.csv, starlevels(* 0.1 ** 0.05 *** 0.01) r2(2) replace
eststo clear

/*Table 7: Productivity of departing human capital */

gen treated_summer_transfer = treated * summer_transfer

eststo:areg shock_pre0_appearance  treated summer_transfer treated_summer_transfer, absorb(shock_year) cluster(shock_club_year)
test summer_transfer + treated_summer_transfer = 0

eststo:areg shock_pre0_minutes  treated summer_transfer treated_summer_transfer, absorb(shock_year) cluster(shock_club_year)
test summer_transfer + treated_summer_transfer = 0

eststo:areg shock_pre0_goals  treated summer_transfer treated_summer_transfer, absorb(shock_year) cluster(shock_club_year)
test summer_transfer + treated_summer_transfer = 0

eststo:areg shock_pre0_assists  treated summer_transfer treated_summer_transfer, absorb(shock_year) cluster(shock_club_year)
test summer_transfer + treated_summer_transfer = 0

esttab using Table7.csv, starlevels(* 0.1 ** 0.05 *** 0.01) r2(2) replace
eststo clear

/*Figure 3: Human capital reallocation*/

preserve 
drop if stay_group == .
collapse (count) total_player = player_identification (sum) pl_player = PL , by (treated stay_group)
gen percentage = pl_player / total_player
gen Treatment = percentage if treated == 1
gen Control = percentage if treated == 0
drop percentage
collapse (sum) Treatment Control, by(stay_group)
graph bar Treatment Control, over(stay_group, relabel(1 "<4" 2 "4-24" 3 ">24")) legend(label(1 "Treatment") label(2 "Control") ) 
graph export Figure3.pdf, replace
restore

/*Table 9: Human capital reallocation*/

eststo: areg PL treated, absorb(shock_year) cluster(shock_club_year)

eststo:areg PL treated summer_transfer treated_summer_transfer, absorb(shock_year) cluster(shock_club_year)
test summer_transfer + treated_summer_transfer = 0

eststo: logit PL treated i.shock_year, cluster(shock_club_year) or

eststo:logit PL treated summer_transfer treated_summer_transfer i.shock_year, cluster(shock_club_year) or
test summer_transfer + treated_summer_transfer = 0

esttab using Table9.csv, starlevels(* 0.1 ** 0.05 *** 0.01) r2(2)  replace
eststo clear

/*Table 10: Long-term impact on human capital productivity*/

eststo: areg post_appearance_pl treated shock_pre0_minutes shock_pre0_goals shock_pre0_assists age, absorb(shock_year) cluster(shock_club_year)

eststo: areg post_appearance_pl treated summer_transfer treated_summer_transfer  shock_pre0_minutes shock_pre0_goals shock_pre0_assists age, absorb(shock_year) cluster(shock_club_year)
test summer_transfer + treated_summer_transfer = 0

eststo: areg post_minutes_pl treated shock_pre0_minutes shock_pre0_goals shock_pre0_assists age, absorb(shock_year) cluster(shock_club_year)

eststo: areg post_minutes_pl treated summer_transfer treated_summer_transfer shock_pre0_minutes shock_pre0_goals shock_pre0_assists age, absorb(shock_year) cluster(shock_club_year)
test summer_transfer + treated_summer_transfer = 0

eststo: areg post_goals_pl treated shock_pre0_minutes shock_pre0_goals shock_pre0_assists age, absorb(shock_year) cluster(shock_club_year)

eststo: areg post_goals_pl treated summer_transfer treated_summer_transfer  shock_pre0_minutes shock_pre0_goals shock_pre0_assists age, absorb(shock_year) cluster(shock_club_year)
test summer_transfer + treated_summer_transfer = 0

eststo: areg post_assists_pl treated shock_pre0_minutes shock_pre0_goals shock_pre0_assists age, absorb(shock_year) cluster(shock_club_year)

eststo: areg post_assists_pl treated summer_transfer treated_summer_transfer shock_pre0_minutes shock_pre0_goals shock_pre0_assists age, absorb(shock_year) cluster(shock_club_year)
test summer_transfer + treated_summer_transfer = 0

esttab using Table10.csv, starlevels(* 0.1 ** 0.05 *** 0.01) r2(2) replace
eststo clear





